


******************NOTICE: The weights are calculated using STATA MP 16.1, in case you use another version, the weights will differ but the overall fit will be similar


******************************EMPLOYMENT to POP 
****to create the synthetic controls fro each treated county
set more off

global path "C:/Users/Reem/Desktop/stata files/"

**Start with creating synthetic controls when employment to pop is the outcome
use "${path}clean_data\Considered Panel.dta", clear

cd "${path}clean_data\Synthetic Control\Employment\Weights"

//Treated counties in 1974
local treated74 1071 18127 22089  42091 48425 

foreach i of local treated74 {
preserve
drop if treated==1 & GEOFIPS!=`i'    //keep only the treated county i and the donor pool (control counties)
tsset GEOFIPS year
  
	set more off

	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(`i') trperiod(1974) xperiod(1969(1)1973) nested fig keep(synth_emp_`i') replace
restore
}

//treated in 1975
local treated75 17141 17197 45091 48321
foreach i of local treated75 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(`i') trperiod(1975) xperiod(1969(1)1974) nested fig keep(synth_emp_`i') replace
restore
}


//treated in 1976
local treated76 4013 29027 33015
foreach i of local treated76 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(`i') trperiod(1976) xperiod(1969(1)1975) nested fig keep(synth_emp_`i') replace
restore
}
	
	
//treated in 1977
local treated77 20031 39085 45021 
foreach i of local treated77 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(`i') trperiod(1977) xperiod(1969(1)1976) nested fig keep(synth_emp_`i') replace
restore
}


//treated in 1978
local treated78 18077 37183 47073 53027
foreach i of local treated78 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(`i') trperiod(1978) xperiod(1969(1)1977) nested fig keep(synth_emp_`i') replace
restore
}

**drop any missing variable 
preserve
drop if treated==1 & GEOFIPS!=28141
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(28141) trperiod(1978) xperiod(1969(1)1977) nested fig keep(synth_emp_28141) replace
restore

preserve
drop if treated==1 & GEOFIPS!=13033   
tsset GEOFIPS year
  
	set more off

	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(13033) trperiod(1974) xperiod(1969(1)1973) nested fig keep(synth_emp_13033) replace
restore

preserve
drop if treated==1 & GEOFIPS!=47169
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(47169) trperiod(1977) xperiod(1969(1)1976) nested fig keep(synth_emp_47169) replace
restore

preserve
drop if treated==1 & GEOFIPS!=17039
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(17039) trperiod(1976) xperiod(1969(1)1975) nested fig keep(synth_emp_17039) replace
restore

*************************************LOG of Wages PC 
***to create the synthetic controls fro each treated county

**Start with creating synthetic controls when log of per capita wages and salaries is the outcome
use "${path}clean_data\Considered Panel.dta", clear
cd "${path}clean_data\Synthetic Control\Wages\Weights"

//Treated counties in 1974 
local treated74  1071 18127 22089  42091 48425 
foreach i of local treated74 {
preserve
drop if treated==1 & GEOFIPS!=`i' //keep only the treated county i and the donor pool (control counties)
tsset GEOFIPS year
  
	set more off

	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(`i') trperiod(1974) xperiod(1969(1)1973) nested fig keep(synth_wage_`i') replace
restore
}

//treated in 1975
local treated75 17141 17197 45091 48321
foreach i of local treated75 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(`i') trperiod(1975) xperiod(1969(1)1974) nested fig keep(synth_wage_`i') replace
restore
}


//treated in 1976
local treated76 4013 29027 33015
foreach i of local treated76 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(`i') trperiod(1976) xperiod(1969(1)1975) nested fig keep(synth_wage_`i') replace
restore
}
	
	
//treated in 1977
local treated77 20031 39085 45021 
foreach i of local treated77 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(`i') trperiod(1977) xperiod(1969(1)1976) nested fig keep(synth_wage_`i') replace
restore
}

//treated in 1978
local treated78 18077 37183 47073 53027
foreach i of local treated78 {
preserve
drop if treated==1 & GEOFIPS!=`i'
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(`i') trperiod(1978) xperiod(1969(1)1977) nested fig keep(synth_wage_`i') replace
restore
}

**drop any missing variable
preserve
drop if treated==1 & GEOFIPS!=28141
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(28141) trperiod(1978) xperiod(1969(1)1977) nested fig keep(synth_wage_28141) replace
restore

preserve
drop if treated==1 & GEOFIPS!=13033
tsset GEOFIPS year
  
	set more off

	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(13033) trperiod(1974) xperiod(1969(1)1973) nested fig keep(synth_wage_13033) replace
restore

preserve
drop if treated==1 & GEOFIPS!=47169
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth log_wages_Rpercapita  `covariates', trunit(47169) trperiod(1977) xperiod(1969(1)1976) nested fig keep(synth_wage_47169) replace
restore

preserve
drop if treated==1 & GEOFIPS!=17039
tsset GEOFIPS year
  
	set more off
	local covariates "emp_rate log_wages_Rpercapita percentage_white percentage_age65plus nonwhite1950 nonwhite1960 nonwhite1970 urban1950 urban1960 urban1970 foreign1950 foreign1960 HS1950 coll4yr1950 sch121960 sch121970 coll4yr1970 med_rent1950 med_rent1960 med_rent1970 owner_occ1950 owner_occ1960 owner_occ1970 renter_occ1960 inc_21950 inc_31960 inc_31970 lowinc1970 LF1950 LF1960 agri1950 agri1960 unemp1950 unemp1960 unemp1970"

synth emp_rate  `covariates', trunit(17039) trperiod(1976) xperiod(1969(1)1975) nested fig keep(synth_emp_17039) replace
restore

